package com.seon.controller;


import com.self.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Seon
 * @date 2022/9/12 13:47
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    // 注入Service
//    @Autowired // 本地注入
     // 远程注入  首先从zookeeper获得userService的url   进行远程调用RPC  将结果封装为代理对象，给变量赋值
    @Reference
    private UserService userService;

    @GetMapping("/sayHello")
    public String sayHello() {
        return userService.sayHello();
    }


    @GetMapping("/allUser")
    public String getAllUser() {
        return userService.getAllUser().toString();
    }
}